package com.zijie.shoprbacapi.service;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zijie.rbac.model.Resource;
import com.zijie.rbac.service.ResourceService;
import com.zijie.shoprbacapi.mapper.ResourceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ResourceServiceImpl implements ResourceService {
    private ResourceMapper resourceMapper;

    //依赖注入
    @Autowired
    public void setResourceMapper(ResourceMapper resourceMapper) {
        this.resourceMapper = resourceMapper;
    }

    //查询全部：
    @Override
    public Page<Resource> findAll(Page<Resource> page, Resource resource) {
        return resourceMapper.findAll(page, resource);
    }

    //新增
    @Override
    public int add(Resource resource) {
        return resourceMapper.insert(resource);
    }

    //修改
    @Override
    public int update(Resource resource) {
        return resourceMapper.updateById(resource);
    }

    //删除一条记录
    @Override
    public int deleteById(Integer id) {
        return resourceMapper.deleteById(id);
    }

    //批量删除
    @Override
    public int deleteByIds(List<Integer> ids) {
        return resourceMapper.deleteByIds(ids);
    }

    //根据id查询一条记录
    @Override
    public Resource findById(Integer id) {
        return resourceMapper.selectById(id);
    }
}
